﻿<Window x:Class="VmroleAuthor.Views.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:vm="clr-namespace:VmroleAuthor.ViewModels"
        xmlns:vw ="clr-namespace:VmroleAuthor.Views"
        Title="VM Role Authoring Tool"        
        Background="White"
        Height="900" Width="1200" 
        Foreground="DarkBlue" FontSize="16"
        Icon="../Img/tool.png"
        AllowDrop="True"
        Drop="MainWindow_OnDrop">

    <!--
    <Window.DataContext>
        <vm:DefinitionViewModel />
    </Window.DataContext>
    -->

    <Window.Resources>
        <Style x:Key="{x:Static ToolBar.ButtonStyleKey}" TargetType="Button">
            <Setter Property="Foreground" Value="DarkBlue"/>
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
        </Style>

        <Style x:Key="{x:Static ToolBar.CheckBoxStyleKey}" TargetType="CheckBox">
            <Setter Property="Foreground" Value="DarkBlue"/>
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
        </Style>

        <Style x:Key="{x:Static ToolBar.MenuStyleKey}" TargetType="Menu">
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="Foreground" Value="DarkBlue"/>
        </Style>       
    </Window.Resources>

    <Grid ShowGridLines ="False">
        <Grid.RowDefinitions>
            <RowDefinition Height="75*" />
            <RowDefinition Height="825*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="300*"/>
            <ColumnDefinition Width="Auto" MinWidth="6"/>
            <ColumnDefinition Width="900*"/>
        </Grid.ColumnDefinitions>

        <GridSplitter Grid.Column="1" Grid.Row="1" HorizontalAlignment="Left" 
                  VerticalAlignment="Stretch" 
                  Background="DarkBlue"
                  Foreground="LightBlue"
                  ResizeBehavior="PreviousAndNext"
                  Width="5" />

        <Border Grid.Row="0" Grid.ColumnSpan="3" BorderThickness="1" BorderBrush="DarkBlue">
            <ToolBarTray  VerticalAlignment="Center" Grid.Row="0" Grid.ColumnSpan="3" Margin="2">

                <ToolBar >
                    <Menu>
                        <MenuItem>
                            <MenuItem.Header>
                                <DockPanel LastChildFill="True">
                                    <Image DockPanel.Dock="Top" Height="20" Width="20" Source="../Img/file-open.ico" />
                                    <Label DockPanel.Dock="Bottom" HorizontalContentAlignment="Center" VerticalAlignment="Center">_File</Label>
                                </DockPanel>
                            </MenuItem.Header>
                            <MenuItem Header="_New Windows Resource Extension Package" Click="File_New_WindowsResourceExtension_Click" ToolTip="New Windows Resource Extension Package (.resextpkg)">
                                <MenuItem.Icon>
                                    <Image Source="..\Img\resext.png" Width="20" Height="20"></Image>
                                </MenuItem.Icon>
                            </MenuItem>
                            <MenuItem Header="_New Linux Resource Extension Package" Click="File_New_LinuxResourceExtension_Click" ToolTip="New Linux Resource Extension Package (.resextpkg)">
                                <MenuItem.Icon>
                                    <Image Source="..\Img\resext.png" Width="20" Height="20"></Image>
                                </MenuItem.Icon>
                            </MenuItem>
                            <Separator />
                            <MenuItem Header="_New Resource Definition Package"  Click="File_New_Resource_Definition_Package_Click" ToolTip="New Resource Definition Package (.resdefpkg)">
                                <MenuItem.Icon>
                                    <Image Source="..\Img\NewResdefPkg.png" Width="20" Height="20"></Image>
                                </MenuItem.Icon>
                            </MenuItem>
                            <MenuItem Header="_New Resource Definition File"  Click="File_New_Resource_Definition_File_Click" ToolTip="New Resource Definition File (.resdef)">
                                <MenuItem.Icon>
                                    <Image Source="..\Img\NewResdefFile.png" Width="20" Height="20"></Image>
                                </MenuItem.Icon>
                            </MenuItem>
                            <Separator />
                            <MenuItem Header="_Open..." Click="Open_File_Click" ToolTip="Open either Resource Definition Package or Resource Extension Package">
                                <MenuItem.Icon>
                                    <Image Source="..\Img\open.ico" Width="20" Height="20"></Image>
                                </MenuItem.Icon>
                            </MenuItem>
                            <Separator />
                            <MenuItem Header="_Save" Command="{Binding SaveAllCommand}" ToolTip="Save all items currently open.">
                                <MenuItem.Icon>
                                    <Image Source="..\Img\save.png" Width="20" Height="20"></Image>
                                </MenuItem.Icon>
                            </MenuItem>
                            <MenuItem Header="_Save As..." ToolTip="Save currently selected item" Command="{Binding DefinitionTreeItemMenuCommandRouter.SaveAsCommand}"  CommandParameter="{Binding ElementName=DefinitionTree, Path=SelectedItem}" >
                                <MenuItem.Icon>
                                    <Image Source="..\Img\save.png" Width="20" Height="20"></Image>
                                </MenuItem.Icon>
                            </MenuItem>
                            <Separator />
                            <MenuItem Header="_Exit" Click="MenuItem_OnExitClick"  ToolTip="Quit this tool" >
                                <MenuItem.Icon>
                                    <Image Source="..\Img\close.ico" Width="20" Height="20"></Image>
                                </MenuItem.Icon>
                            </MenuItem>
                        </MenuItem>
                    </Menu>
                    <Menu >
                        <MenuItem>
                            <MenuItem.Header>
                                <DockPanel LastChildFill="True">
                                    <Image DockPanel.Dock="Top" Height="20" Width="20" Source="../Img/edit.png" />
                                    <Label DockPanel.Dock="Bottom" HorizontalContentAlignment="Center" VerticalAlignment="Center">_ClipBoard</Label>
                                </DockPanel>
                            </MenuItem.Header>
                            <MenuItem Header="_Cut" Command="Cut" ToolTip="Cut selection to Windows Clipboard.">
                                <MenuItem.Icon>
                                    <Image Source="../img/cut.png" Width="20" Height="20"/>
                                </MenuItem.Icon>
                            </MenuItem>
                            <MenuItem Header="_Copy" Command="Copy" ToolTip="Copy selection to Windows Clipboard.">
                                <MenuItem.Icon>
                                    <Image Source="../img/copy.ico"  Width="20" Height="20"/>
                                </MenuItem.Icon>
                            </MenuItem>
                            <MenuItem Header="_Paste" Command="Paste" ToolTip="Paste from Windows Clipboard." >
                                <MenuItem.Icon>
                                    <Image Source="../img/paste.png" Width="20" Height="20"/>
                                </MenuItem.Icon>
                            </MenuItem>
                        </MenuItem>
                    </Menu>
                    <Menu >
                        <MenuItem>
                            <MenuItem.Header>
                                <DockPanel LastChildFill="True">
                                    <Image DockPanel.Dock="Top" Height="20" Width="20" Source="../Img/view.png" />
                                    <Label DockPanel.Dock="Bottom" HorizontalContentAlignment="Center" VerticalAlignment="Center">_View</Label>
                                </DockPanel>
                            </MenuItem.Header>
                            <MenuItem Header="_View Working Directory" ToolTip="Temp directory which contains the json file(s) and the application payloads. The contents of this directory will be packaged when saved." Command="{Binding DefinitionTreeItemMenuCommandRouter.ViewWorkingDirectoryCommand}"  CommandParameter="{Binding ElementName=DefinitionTree, Path=SelectedItem}">
                                <MenuItem.Icon>
                                    <Image Source="..\Img\FileFolder.ico" Width="20" Height="20"></Image>
                                </MenuItem.Icon>
                            </MenuItem>
                        </MenuItem>

                    </Menu>
                </ToolBar>
                <ToolBar>
                    <Button Command="{Binding SaveAllCommand}" ToolTip="Save all currently open items." >
                        <DockPanel LastChildFill="True" Height="{Binding Height, ElementName=button}">
                            <Image DockPanel.Dock="Top" Height="20" Width="20"  Source="../Img/save.png" />
                            <Label DockPanel.Dock="Bottom" HorizontalContentAlignment="Center" VerticalAlignment="Center">Save</Label>
                        </DockPanel>
                    </Button>
                    <Button Command="{Binding ValidateAllCommand}"  ToolTip="Validate all currently open items for errors and warnings." >
                        <DockPanel LastChildFill="True" Height="{Binding Height, ElementName=button}">
                            <Image DockPanel.Dock="Top" Height="20" Width="20"  Source="../Img/validate.png" />
                            <Label DockPanel.Dock="Bottom" HorizontalContentAlignment="Center" VerticalAlignment="Center">Validate</Label>
                        </DockPanel>
                    </Button>
                </ToolBar>
                <ToolBar>
                    <Menu>
                        <MenuItem>
                            <MenuItem.Header>
                                <DockPanel LastChildFill="True" ToolTip="Add child element to the selected item in the model. Context sensitive. Only applicable items in the model will be allowed to be added.">
                                    <Image DockPanel.Dock="Top" Height="20" Width="20" Source="../Img/addgreen.png" />
                                    <Label DockPanel.Dock="Bottom" HorizontalContentAlignment="Center" VerticalAlignment="Center">_Add</Label>
                                </DockPanel>
                            </MenuItem.Header>
                            <MenuItem Header="_Web Application" Command="{Binding DefinitionTreeItemMenuCommandRouter.AddWebDeployCommand}"  CommandParameter="{Binding ElementName=DefinitionTree, Path=SelectedItem}">
                                <MenuItem.Icon>
                                    <Image Source="..\Img\webdeploy.png" Width="20" Height="20"></Image>
                                </MenuItem.Icon>
                                <MenuItem.ToolTip>
                                    <ToolTip>To: Application Profile</ToolTip>
                                </MenuItem.ToolTip>
                            </MenuItem>
                            <MenuItem Header="S_QL DAC Application" Command="{Binding DefinitionTreeItemMenuCommandRouter.AddSqldacCommand}"  CommandParameter="{Binding ElementName=DefinitionTree, Path=SelectedItem}">
                                <MenuItem.Icon>
                                    <Image Source="..\Img\sqldac.png" Width="20" Height="20"></Image>
                                </MenuItem.Icon>
                                <MenuItem.ToolTip>
                                    <ToolTip>To: Application Profile</ToolTip>
                                </MenuItem.ToolTip>
                            </MenuItem>
                            <MenuItem Header="_Script Application" Command="{Binding DefinitionTreeItemMenuCommandRouter.AddScriptAppCommand}"  CommandParameter="{Binding ElementName=DefinitionTree, Path=SelectedItem}">
                                <MenuItem.Icon>
                                    <Image Source="..\Img\scriptapplication.ico" Width="20" Height="20"></Image>
                                </MenuItem.Icon>
                                <MenuItem.ToolTip>
                                    <ToolTip>To: Application Profile</ToolTip>
                                </MenuItem.ToolTip>
                            </MenuItem>
                            <Separator />
                            <MenuItem Header="_Provisioning Script" Command="{Binding DefinitionTreeItemMenuCommandRouter.AddProvisioningScriptCommand}"  CommandParameter="{Binding ElementName=DefinitionTree, Path=SelectedItem}">
                                <MenuItem.Icon>
                                    <Image Source="..\Img\provscript.png" Width="20" Height="20"></Image>
                                </MenuItem.Icon>
                                <MenuItem.ToolTip>
                                    <ToolTip>To: Application Profile</ToolTip>
                                </MenuItem.ToolTip>
                            </MenuItem>
                            <Separator/>
                            <MenuItem Header="S_cript Command"  Command="{Binding DefinitionTreeItemMenuCommandRouter.AddScriptCommandCommand}"  CommandParameter="{Binding ElementName=DefinitionTree, Path=SelectedItem}" >
                                <MenuItem.Icon>
                                    <Image Source="..\Img\scriptcommand.png" Width="20" Height="20"></Image>
                                </MenuItem.Icon>
                                <MenuItem.ToolTip>
                                    <ToolTip>To: Web Deploy or SQL DAC or Script Application</ToolTip>
                                </MenuItem.ToolTip>
                            </MenuItem>
                            <Separator />
                            <MenuItem Header="SQ_L Script Command" Command="{Binding DefinitionTreeItemMenuCommandRouter.AddSqlScriptCommandCommand}"  CommandParameter="{Binding ElementName=DefinitionTree, Path=SelectedItem}">
                                <MenuItem.Icon>
                                    <Image Source="..\Img\sqlscript.png" Width="20" Height="20"></Image>
                                </MenuItem.Icon>
                                <MenuItem.ToolTip>
                                    <ToolTip>To: SQL DAC Application</ToolTip>
                                </MenuItem.ToolTip>
                            </MenuItem>
                            <Separator />
                            <MenuItem Header="SQL _Profile" Command="{Binding DefinitionTreeItemMenuCommandRouter.AddSqlProfileCommand}"  CommandParameter="{Binding ElementName=DefinitionTree, Path=SelectedItem}">
                                <MenuItem.Icon>
                                    <Image Source="..\Img\sqlprofile.png" Width="20" Height="20"></Image>
                                </MenuItem.Icon>
                                <MenuItem.ToolTip>
                                    <ToolTip>To: Application Profile</ToolTip>
                                </MenuItem.ToolTip>
                            </MenuItem>
                            <MenuItem Header="SQL _Deployment" Command="{Binding DefinitionTreeItemMenuCommandRouter.AddSqlDeploymentCommand}"  CommandParameter="{Binding ElementName=DefinitionTree, Path=SelectedItem}">
                                <MenuItem.Icon>
                                    <Image Source="..\Img\sqldeployment.png" Width="20" Height="20"></Image>
                                </MenuItem.Icon>
                                <MenuItem.ToolTip>
                                    <ToolTip>To: SQL Profile</ToolTip>
                                </MenuItem.ToolTip>
                            </MenuItem>
                            <Separator />
                            <MenuItem Header="_Network Adapter" Command="{Binding DefinitionTreeItemMenuCommandRouter.AddNetworkAdapterCommand}"  CommandParameter="{Binding ElementName=DefinitionTree, Path=SelectedItem}">
                                <MenuItem.Icon>
                                    <Image Source="..\Img\nic.png" Width="20" Height="20"></Image>
                                </MenuItem.Icon>
                                <MenuItem.ToolTip>
                                    <ToolTip>To: Network Profile</ToolTip>
                                </MenuItem.ToolTip>
                            </MenuItem>
                            <Separator />
                            <MenuItem Header="_View Definition Section" Command="{Binding DefinitionTreeItemMenuCommandRouter.AddViewDefSectionCommand}"  CommandParameter="{Binding ElementName=DefinitionTree, Path=SelectedItem}">
                                <MenuItem.Icon>
                                    <Image Source="..\Img\section.png" Width="20" Height="20"></Image>
                                </MenuItem.Icon>
                                <MenuItem.ToolTip>
                                    <ToolTip>To: View Definition Section</ToolTip>
                                </MenuItem.ToolTip>
                            </MenuItem>
                            <MenuItem Header="View Definition _Category" Command="{Binding DefinitionTreeItemMenuCommandRouter.AddViewDefCategoryCommand}"  CommandParameter="{Binding ElementName=DefinitionTree, Path=SelectedItem}">
                                <MenuItem.Icon>
                                    <Image Source="..\Img\viewdefcategory.png" Width="20" Height="20"></Image>
                                </MenuItem.Icon>
                                <MenuItem.ToolTip>
                                    <ToolTip>To: View Definition Category</ToolTip>
                                </MenuItem.ToolTip>
                            </MenuItem>
                        </MenuItem>
                    </Menu>
                    <Button Command="{Binding DefinitionTreeItemMenuCommandRouter.RemoveTreeItemCommand}"  CommandParameter="{Binding ElementName=DefinitionTree, Path=SelectedItem}" ToolTip="Remove selected selected item and its descendant(s).">
                        <DockPanel LastChildFill="True" Height="{Binding Height, ElementName=button}">
                            <Image DockPanel.Dock="Top" Height="20" Width="20"  Source="../Img/deletered.png" />
                            <Label DockPanel.Dock="Bottom" HorizontalContentAlignment="Center" VerticalAlignment="Center">Remove</Label>
                        </DockPanel>
                    </Button>
                </ToolBar>
                <ToolBar>
                    <Menu>
                        <MenuItem>
                            <MenuItem.Header>
                                <DockPanel LastChildFill="True" ToolTip="Deploy">
                                    <Image DockPanel.Dock="Top" Height="20" Width="20" Source="../Img/deploy_32.png" />
                                    <Label DockPanel.Dock="Bottom" HorizontalContentAlignment="Center" VerticalAlignment="Center">_Deploy</Label>
                                </DockPanel>
                            </MenuItem.Header>
                            <MenuItem Header="_Deploy Resource Extension to Microsoft Azure" Command="{Binding DefinitionTreeItemMenuCommandRouter.DeployResExtToAzureCommand}"  CommandParameter="{Binding ElementName=DefinitionTree, Path=SelectedItem}">
                                <MenuItem.Icon>
                                    <Image Source="..\Img\deploy_32.png" Width="20" Height="20"></Image>
                                </MenuItem.Icon>
                                <MenuItem.ToolTip>
                                    <ToolTip>Deploy Resource Extension to Microsoft Azure</ToolTip>
                                </MenuItem.ToolTip>
                            </MenuItem>
                        </MenuItem>
                    </Menu>
                </ToolBar>
                <ToolBar>
                    <Button x:Name="HelpButton" Click="HelpButton_OnClick">
                        <DockPanel LastChildFill="True" Height="{Binding Height, ElementName=button}">
                            <Image DockPanel.Dock="Top" Height="20" Width="20"  Source="../Img/help.png" />
                            <Label DockPanel.Dock="Bottom" HorizontalContentAlignment="Center" VerticalAlignment="Center">About</Label>
                        </DockPanel>
                    </Button>
                </ToolBar>               
            </ToolBarTray >
        </Border>

        <ScrollViewer Grid.Row="1" Grid.Column="0" CanContentScroll="True" HorizontalScrollBarVisibility="Auto">
            <TreeView x:Name="DefinitionTree" ItemsSource="{Binding RootTreeViewItemViewModels}" SelectedItemChanged="DefinitionTree_OnSelectedItemChanged" >
                <TreeView.ItemContainerStyle>
                    <!--  This Style binds a TreeViewItem to a TreeViewItemViewModel. -->
                    <Style TargetType="{x:Type TreeViewItem}">
                        <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
                        <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
                        <Setter Property="FontWeight" Value="Normal" />
                        <Style.Triggers>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter Property="FontWeight" Value="Bold" />
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </TreeView.ItemContainerStyle>

                <TreeView.Resources>
                    <HierarchicalDataTemplate DataType="{x:Type vm:VmRoleResourceExtensionViewModel}" ItemsSource="{Binding Children }">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/resext.png" />
                            <TextBlock Text="{Binding Identity}" />
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <DataTemplate DataType="{x:Type vm:ResourceExtensionDataPackageViewModel}" >
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/package.png" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </DataTemplate>

                    <DataTemplate DataType="{x:Type vm:ResourceExtensionRequirementsViewModel}">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/ResRequirements.png" />
                            <TextBlock Text="{Binding ResourceRequirementsSummary}" />
                        </StackPanel>
                    </DataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type vm:ApplicationProfileViewModel}" ItemsSource="{Binding Children }">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/ApplicationProfile_32.png" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <DataTemplate DataType="{x:Type vm:ParametersViewModel}">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/params.png" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </DataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type vm:WebDeployApplicationViewModel}" ItemsSource="{Binding Children }">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/webdeploy.png" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type vm:ScriptApplicationViewModel}" ItemsSource="{Binding Children }">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/scriptapplication.ico" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type vm:SqlDacApplicationViewModel}" ItemsSource="{Binding Children }">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/sqldac.png" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type vm:SqlProfileViewModel}" ItemsSource="{Binding Children }">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/sqlprofile.png" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <DataTemplate DataType="{x:Type vm:SqlScriptViewModel}">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/sqlscript.png" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </DataTemplate>

                    <DataTemplate DataType="{x:Type vm:SqlDeploymentViewModel}">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/sqldeployment.png" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </DataTemplate>

                    <DataTemplate DataType="{x:Type vm:ProvisioningScriptViewModel}">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/scriptcommand.png" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </DataTemplate>

                    <DataTemplate DataType="{x:Type vm:WindowsServerRolesAndFeaturesViewModel}">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/windowsfeatures.png" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </DataTemplate>

                    <DataTemplate DataType="{x:Type vm:RunOnceCommandsViewModel}">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/runonce.png" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </DataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type vm:VmRoleResourceDefinitionViewModel}" ItemsSource="{Binding Children }">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/Resdef.png" />
                            <TextBlock Text="{Binding Identity}" />
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <DataTemplate DataType="{x:Type vm:ResourceExtensionReferenceViewModel}">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/extensionref.png" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </DataTemplate>

                    <DataTemplate DataType="{x:Type vm:HardwareProfileViewModel}">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/HardwareProfile.png" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </DataTemplate>

                    <DataTemplate DataType="{x:Type vm:ScaleOutSettingsViewModel}">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/scaleout_32.png" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </DataTemplate>

                    <DataTemplate DataType="{x:Type vm:StorageProfileViewModel}">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/storageprofile.png" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </DataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type vm:NetworkProfileViewModel}" ItemsSource="{Binding Children }">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/networkprofile.png" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <DataTemplate DataType="{x:Type vm:NetworkAdapterViewModel}">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/nic.png" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </DataTemplate>

                    <DataTemplate DataType="{x:Type vm:OperatingSystemProfileViewModel}">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/osprofile.png" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </DataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type vm:ViewDefViewModel}" ItemsSource="{Binding Children }">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/viewdef.png" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type vm:ViewDefSectionViewModel}" ItemsSource="{Binding Children }">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/section.png" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type vm:ViewDefCategoryViewModel}" ItemsSource="{Binding Children }">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/category.png" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type vm:ViewDefResourcesContainerViewModel}" ItemsSource="{Binding Children }">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/resources.png" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <DataTemplate DataType="{x:Type vm:ViewDefResourcesViewModel}">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Margin="3,0" Source="../Img/resource.png" />
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </DataTemplate>

                </TreeView.Resources>
            </TreeView>
        </ScrollViewer>


        <Grid Grid.Column="2" Grid.Row="1" ShowGridLines="False">
            <Grid.RowDefinitions>
                <RowDefinition Height="600*" />
                <RowDefinition Height="132*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            
            <Grid.Resources>             
                <vw:CloudServiceValidationResultDataTemplateSelector x:Key="ModelValidationDataTemplateSelector"/>
                <vw:JsonViewConvertor x:Key="JsonViewConverter"/>
            </Grid.Resources>


            <ScrollViewer  Grid.Row="0" Grid.Column="0" CanContentScroll="True" HorizontalScrollBarVisibility="Auto">
                <TabControl SelectedIndex="{Binding SelectedTabIndex}">
                    <TabItem Header="Editor">
                        <ContentControl  Content="{Binding SelectedItem , ElementName=DefinitionTree}">
                        </ContentControl>
                    </TabItem>
                    <TabItem Header="JSON View">
                        <ContentPresenter  Content="{Binding SelectedItem , ElementName=DefinitionTree, Converter={StaticResource JsonViewConverter}}">
                        </ContentPresenter>
                    </TabItem>                  
                </TabControl>                
            </ScrollViewer>
                        
            <GridSplitter Grid.Row="0" Grid.ColumnSpan="1" HorizontalAlignment="Stretch" 
                  VerticalAlignment="Bottom" 
                  Background="DarkBlue"  
                  Foreground="LightBlue"
                  Height="5" />

            <ScrollViewer Grid.Row="1" Grid.Column="0" CanContentScroll="True" HorizontalScrollBarVisibility="Auto">
                <ListBox x:Name="ValidationErrorsList" 
                         ItemsSource="{Binding Path=ValidationResults}"
                         ItemTemplateSelector="{StaticResource ModelValidationDataTemplateSelector}"
                         >
                    <ListBox.Resources>
                        <Style TargetType="{x:Type ListBoxItem}">
                            <EventSetter Event="MouseDoubleClick" Handler="HandleValidationResultsDoubleClick" />
                        </Style>
                    </ListBox.Resources>                  
                </ListBox>
            </ScrollViewer>

        </Grid>

    </Grid>

</Window>
